package com.example.demo.Bean;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

public class Show {
    private Weather mWeather;
    private List<Weather.ResultsBean> results;
    private Weather.ResultsBean.LocationBean loaction;
    private Weather.ResultsBean.NowBean now;

    public void initdata() {
        results = mWeather.getResults();
        loaction = results.get(0).getLocation();
        now = results.get(0).getNow();
    }

    public String getShow() {
        String util1 = "<font color='#E6E6E6'>";
        String util2 = "</font>";
        String show = "<br/>";
        show += "&emsp&emsp&emsp"+util1+"能见度："+util2+"&emsp "+"<big>"+now.getVisibility()+" Km/h</big>"+"<br/><br/>";
        show += "&emsp&emsp&emsp"+util1+"当前风速："+util2+" "+"<big>"+now.getWind_speed()+" Km/h</big>"+"<br/><br/>";
        show += "&emsp&emsp&emsp"+util1+"体感温度："+util2+" "+"<big>"+now.getFeels_like()+" ℃</big>"+"<br/><br/>";
        show += "&emsp&emsp&emsp"+util1+"当前湿度："+util2+" "+"<big>"+now.getHumidity()+".0 %</big>"+"<br/><br/>";
        show += "&emsp&emsp&emsp"+util1+"当前云量："+util2+" "+"<big>"+now.getClouds()+".0 %</big>"+"<br/><br/>";
        show += "&emsp&emsp&emsp"+util1+"当前气压："+util2+" "+"<big>"+now.getPressure()+" hPa</big>"+"<br/><br/>";
        return show;
    }

    public String getOther() {
        initdata();
        String str1 = now.getText();
        String str2 = now.getWind_direction()+"风"+now.getWind_scale()+"级";
        return str1 + " | " + str2;
    }

    public String getDate() {
        String tmp = mWeather.getResults().get(0).getLast_update();
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String str = sdf.format(date);
        tmp = tmp.substring(14, 16);
        str = str.substring(14, 16);
        int len = (60 + Integer.parseInt(str) - Integer.parseInt(tmp)) % 60;
        return String.valueOf(len) + "分钟前更新";
    }

    public String getTips() {
        String tips = "       温馨提示:";
        if(!now.getText().contains("雨") && Integer.parseInt(now.getTemperature()) <= 30 && Integer.parseInt(now.getTemperature()) >= 15)
            tips += "  天气不错，可以适当运动运动";
        if(Integer.parseInt(now.getHumidity()) <= 30)
            tips += "  空气略显干燥，注意补充水分，以保身体健康";
        if(Integer.parseInt(now.getHumidity()) >= 80)
            tips += "  空气湿度过高，可以适当通风透气，以保身体健康";
        if(now.getText().contains("雨"))
            tips += "  请您注意防寒，外出及时添衣保暖，带好雨具，预防感冒";
        if(Integer.parseInt(now.getTemperature()) >= 30)
            tips += "  高温天气，请注意不要在室外长时间逗留";
        if(Integer.parseInt(now.getTemperature()) <= 12)
            tips += "  天气逐渐转凉，请多穿衣服，注意保暖";
        if(tips.equals("       温馨提示:"))
            tips += "  天气不错，希望今天对于您来说是幸福美满的一天。";
        else tips += "。";
        return tips;
    }

    public void setmWeather(Weather mWeather) {
        this.mWeather = mWeather;
    }

    public Weather getmWeather() {
        return mWeather;
    }
}
